package com.cskaoyan.controller;

import com.cskaoyan.bean.category.BaseRespVo;
import com.cskaoyan.bean.category.BasePageData;
import com.cskaoyan.bean.category.Category;
import com.cskaoyan.service.CategoryService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("admin/category")
public class CategoryController {
    @Autowired
    CategoryService categoryService;

    @RequiresPermissions(value = "admin:category:list")
    @RequestMapping("list")
    public BaseRespVo categoryList(){
        BasePageData pageData=categoryService.categoryList();
        return BaseRespVo.ok(pageData);
    }
    @RequestMapping("l1")
    public BaseRespVo categoryl1(){
        BasePageData pageData=categoryService.categoryL1();
        return BaseRespVo.ok(pageData);

    }

    @RequiresPermissions(value = "admin:category:update")
    @RequestMapping("update")
    public BaseRespVo updateCategory(@RequestBody Category category){
        categoryService.updateCategory(category);
        return BaseRespVo.ok();
    }

    @RequiresPermissions(value = "admin:issue:create")
    @RequestMapping("create")
    public BaseRespVo createCategory(@RequestBody Category category){
        categoryService.createCategory(category);
        return BaseRespVo.ok(category);
    }

    @RequiresPermissions(value = "admin:issue:delete")
    @RequestMapping("delete")
    public BaseRespVo deleteCategory(@RequestBody Category category){
        categoryService.deleteCategory(category);
        return BaseRespVo.ok();
    }
}
